home *** CD-ROM | disk | FTP | other *** search
- /*
- File: ExampleClass.h
-
- Contains: Declarations for the TExampleClass
-
- Copyright: © 1991-1993 by Apple Computer, Inc., all rights reserved.
-
- */
-
-
- #ifndef __EXAMPLECLASS__
- #define __EXAMPLECLASS__
-
-
- // the functionset ID for the example library
- #define kExampleFunctionSet "appl:exam$ExampleFSet,1.1"
-
- #ifndef __LIBRARYMANAGER__
- #include <LibraryManager.h>
- #endif
-
- #ifdef __cplusplus
-
- #ifndef __LIBRARYMANAGERCLASSES__
- #include <LibraryManagerClasses.h>
- #endif
-
- typedef unsigned long ulong;
- typedef char* (* MPWC HelloCPtr)(ulong*);
- typedef pascal Ptr (*HelloPPtr)(ulong&);
- //
- // If we're compiling a Symantec C++ library, undefine MPWC
- // We define _CDECL to be _cdecl so that the destructor will be
- // "C" calling conventions. Otherwise, we define _CDECL to be
- // whatever MPWC already is.
- //
- #if __SCLIBRARY__
- #undef MPWC
- #define MPWC
- #define _CDECL _cdecl
- #else
- #define _CDECL MPWC
- #endif
-
- /**********************************************************************
- ** class TExampleClass
- ***********************************************************************/
-
- #define kTExampleClassID "appl:exam$TExampleClass,1.1"
-
- #if __SCLIBRARY__
- class TExampleClass : public TSCDynamic
- #else
- class TExampleClass : public TDynamic
- #endif
- {
- public:
- MPWC TExampleClass();
- virtual ~ _CDECL TExampleClass();
-
- // New Methods
-
- virtual char* MPWC GetObjectName() const;
- virtual void MPWC SetObjectName(char *theName);
-
- virtual void MPWC DoThisAndThat();
- virtual void MPWC DoThat();
-
- virtual void MPWC SetGlobalInt(long theValue);
- virtual long MPWC GetGlobalInt();
-
- // Public non-virtual function
- // Dynamically exported by using ExportFunction
- void MPWC GetGlobalRef(long*&);
-
- // Public static function
- // Dynamically exported by the ExportFunction
- static Boolean MPWC Test(ulong test);
- static Boolean MPWC Test(char* test);
-
- private:
- char *fName;
-
- // static gExampleClassCount counts the number of instances
- static long gExampleClassCount;
- };
-
-
- extern "C" char* HelloC(ulong*);
- ulong Goodbye();
- //
- // Unfortunately, Symantec C++ does not handle overloaded _cdecl functions,
- // even though it handles overloaded _cdecl methods, so we resort to a hack
- // here. If we're compiling with Symantec - we use the mangled names of the
- // "C" Functions to allow the link to work. Of course, if we compile
- // ExampleClass with Symantec C++, and link it with Symantec C++ this problem
- // doesn't exist.
- //
- #if defined(THINK_CPLUS)
- pascal Ptr HELLOPASCAL(ulong& theHelloTicks);
- pascal ulong GOODBYEPASCAL();
- #else
- pascal Ptr HelloPascal(ulong& theHelloTicks);
- pascal ulong GoodbyePascal();
- #endif
-
- #if defined(THINK_CPLUS) && !__SCLIBRARY__
-
- #define kHelloRef Hello__FRUl
- #define kHelloPtr Hello__FPUl
-
- char* MPWC Hello__FRUl(ulong&);
- char* MPWC Hello__FPUl(ulong*);
- #else
-
- #define kHelloRef Hello
- #define kHelloPtr Hello
-
- char* Hello(ulong&);
- char* Hello(ulong*);
- #endif
-
- #else
-
- typedef void TExampleClass;
-
- /* Inline message dispatching code */
- #define JSRA1 0x4e91
- #define dispatchMessage(routineID) \
- {0x2057,0x2050,0x2268,(4*routineID),JSRA1}
-
- void ExDestructor(TExampleClass* this) = dispatchMessage(1);
- char* ExGetObjectName(TExampleClass* this) = dispatchMessage(9);
- void ExSetObjectName(TExampleClass* this, char *theName) = dispatchMessage(10);
- void ExDoThisAndThat(TExampleClass* this) = dispatchMessage(11);
- void ExDoThat(TExampleClass* this) = dispatchMessage(12);
- void ExSetGlobalInt(TExampleClass* this, long theValue) = dispatchMessage(13);
- long ExGetGlobalInt(TExampleClass* this) = dispatchMessage(14);
-
- char* Hello();
-
- #endif
- #endif
-